﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

//[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace Reports
{

    public class Log
    {
        static log4net.ILog loginfo = null;

        public static void WriteLog(Exception ex)
        {
            if (loginfo == null)
            {
                loginfo = log4net.LogManager.GetLogger("loginfo");   //选择<logger name="loginfo">的配置  
                log4net.Config.XmlConfigurator.Configure();
            }


            loginfo.Error("在出现未处理的错误时运行的代码--" +
            string.Format("\r\n错误摘要:{0}\r\n错误源{1}\r\n错误详细信息{2}",
                ex.Message,
                ex.Source,
                ex.ToString()), ex);
        }

        public static void WriteLog(string message)
        {

            if (loginfo == null)
            {
                loginfo = log4net.LogManager.GetLogger("loginfo");   //选择<logger name="loginfo">的配置  
                log4net.Config.XmlConfigurator.Configure();
            }
            loginfo.Info(message);

            //loginfo.Info(message);
        }
    }
}
